<?php
	include 'search_bar.php'; 
    // http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html
?>

<div id="table">
	<table cellspacing="0" cellpadding="0">
	  <tr>
	    <th><?php echo $this->Paginator->sort('name', 'Názov výzvy'); ?></th>
	    <th><?php echo $this->Paginator->sort('description', 'Popis výzvy'); ?></th>
	    <th><?php echo $this->Paginator->sort('Agency.name', 'Agentúra'); ?></th>
	    <th><?php echo $this->Paginator->sort('is_deleted', 'Neaktívná'); ?></th>
	    <th class="actions">Akcie</th>
	  </tr>
	<?php 
	  foreach($calls as $call){
	      echo '<tr class="hov' . ($call['Call']['is_deleted'] == 1 ? ' deleted' : '') . '">';
	      echo '<td>' . '<b>'.$this->Html->link($call['Call']['name'], array('admin' => false, 'controller' => 'calls', 'action' => 'detail', $call['Call']['id'])).'</b>' . '</td>';
	      echo '<td>' . $call['Call']['description'] . '</td>';
	      echo '<td title="'.$call['Agency']['fullname'].'">' . $call['Agency']['name'] . '</td>';
	      echo '<td>' . ($call['Call']['is_deleted'] ? 'Áno' : 'Nie') . '</td>';
	      ?>
	      <td class="last actions">
	        	<?php 
	        		echo $this->Html->link(
	        			$this->Html->image(BASE_URL . '/img/edit.gif', array('alt' => 'Edit')), 
	        			array('admin' => true, 'controller' => 'calls', 'action' => 'edit', $call['Call']['id']),
	        			array('escape' => false, 'class' => 'edit')
	        		);
	        		echo ' &nbsp; ';
	        		echo $this->Html->link(
	        			$this->Html->image(BASE_URL . '/img/delete.gif', array('alt' => 'Deleted')), 
	        			array('admin' => true, 'controller' => 'calls', 'action' => 'delete', $call['Call']['id']),
	        			array('escape' => false, 'class' => 'delete'),
	        			ARE_YOU_SURE
	        		);
	        	?> 
	        </td><?php 
	      echo '</tr>';     
	  }
	?>
	</table>
</div>
<div class="paging">
<?php 
$params = $this->Paginator->params();
if ($params['pageCount'] > 1 ) {
// Shows the page numbers
//echo $this->Paginator->numbers();
echo ' ';
// Shows the prev link
echo $this->Paginator->prev('« Predchádzajúca', null, null, array('class' => 'disabled'));
echo ' ';
// prints X of Y, where X is current page and Y is number of pages
echo $this->Paginator->numbers();//echo $this->Paginator->counter();
echo ' ';
// Shows the next link
echo $this->Paginator->next('Nasledujúca »', null, null, array('class' => 'disabled'));
}
?>
</div>

<?php echo $this->element('limit'); ?>
